#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:do_tcp_receive.py
# author:Jackiex
# datetime:2023/5/29 11:38
# software: PyCharm

"""
this is function  description 
"""

import socket

TCP_IP = '127.0.0.1'
TCP_PORT = 5005
BUFFER_SIZE = 1024

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((TCP_IP, TCP_PORT))
s.listen(1)

conn, addr = s.accept()
print('Connection address:', addr)
while True:
    data = conn.recv(BUFFER_SIZE)
    if not data: break
    print("received data:", data.decode())
    conn.send(data)  # echo
conn.close()
